import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:jinke/page/pro_list/subs/pro_detail/subs/pro_progress/widgets/cell.dart';
import 'package:jinke/utils/util.dart';

import '../../model/pro_phase_model/pro_phase_model.dart';
import 'index.dart';

class ProProgressPage extends StatelessWidget {
  ProProgressPage({
    Key? key,
    this.list,
  }) : super(key: key) {
    controller.state.phaseList = list;
  }
  final controller = Get.put(ProProgressController());
  final List<ProPhaseModel>? list;
  // 主视图
  Widget _buildView() {
    var state = controller.state;
    return ListView(
        padding: EdgeInsets.only(top: 16.r),
        children: state.phaseList
                ?.asMap()
                .map((key, e) => MapEntry(
                    key,
                    ProProgressCell(
                      isFirst: key == 0,
                      isLast: key == (state.phaseList?.length ?? 0) - 1,
                      title: e.phaseName ?? '',
                      rightTitle: e.phaseCompleteTime,
                      content: e.phaseSummary ?? '',
                      status: e.phaseOrder ?? 0,
                    )))
                .values
                .toList() ??
            []);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ProProgressController>(
      id: "pro_progress",
      builder: (_) {
        return Scaffold(
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
